/**
 * 海底牌窗口
 * Created by duwei on 2018/4/26.
 */
var Ma_HaiDiPaiWindow = Window.extend({
    _blockBack: false,
    /**
     * 工程资源
     * @private
     */
    _ccsFileName :res.Ma_HaiDiPaiWindow_json,
    initWindow: function () {
        this._initHaiDiPaiWindow();
    },
    _initHaiDiPaiWindow: function () {
        var self = this;
        TouchUtil.setOnclickListener(self._nodeList['root.btn_ok'], function () {
            network.send(4051, {room_id: gameData.roomId, val: 1});
        });
        TouchUtil.setOnclickListener(self._nodeList['root.btn_cancel'], function () {
            network.send(4051, {room_id: gameData.roomId, val: 0});
        });
    },
    refreshData: function (arr) {
        var haveISelected = false;
        for (var i = 0; i < arr.length; i++) {
            if (arr[i].uid == gameData.uid && arr[i].val) {
                haveISelected = true;
                break;
            }
        }
        var content = "请选择是否要海底牌, 优先级按以下顺序" + "\n\n";
        var selectedUid = {};
        for (var i = 0; i < arr.length; i++) {
            selectedUid[arr[i].uid] = true;
            content += "【" + gameData.playerMap[arr[i].uid].nickname + "】 " + (arr[i]['val'] ? "已选" : "等待选择") + "\n";
        }
        var self = this;
        self._nodeList['root.lb_content'].setString(content);
        if (haveISelected) {
            self._nodeList['root.btn_ok'].setVisible(false);
            self._nodeList['root.btn_cancel'].setVisible(false);
        }
    }
});